package net.csdra.libraryborrowing.service.book;

import net.csdra.libraryborrowing.domain.book.BookCopyLog;
import net.csdra.libraryborrowing.domain.book.BookCopyLogRepository;
import net.csdra.libraryborrowing.util.Utils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by xiaomi on 2017/10/17.
 */
@Component
public class BookCopyLogComponentImpl implements BookCopyLogComponent {

    @Autowired
    BookCopyLogRepository bookCopyLogRepository;

    @Override
    public BookCopyLog createBookCopyLog(CreateBookCopyLog createBookCopyLog) {
        BookCopyLog bookCopyLog = Utils.createAutoSet(BookCopyLog.class, null);
        Utils.copy(createBookCopyLog, bookCopyLog);
        bookCopyLogRepository.save(bookCopyLog);
        BookCopyLog returnValue = new BookCopyLog();
        BeanUtils.copyProperties(bookCopyLog, returnValue);
        return returnValue;
    }
}
